// pages/mine/mine.js

var WxParse = require("../../wxParse/wxParse.js");
var api = require("../../api.js"),
    e = require("../../utils/util.js"),
    r = "",
    app = getApp();
Page({
    /**
     * 页面的初始数据
     */
    data: {
      windowWidth: 0, //页面视图宽度
      windowHeight: 0, //视图高度
    },
    onLoad: function (options) {
         r =this;
         wx.getSystemInfo({
          success: function (res) {
          console.log(res)
          var windowHeight = res.windowHeight;
          //两列，每列的图片宽度
          var height = (windowHeight - 260) ;
          r.setData({
           windowHeight: height,
          }, function () {
           r.initData(); //初始化数据
          });
          },
         })
      },
      onShow: function () {
        // r.initData();
      }, 
      initData:function(){
        wx.showLoading({
          title: '加载中',
         })
        var t= new Object();
        t.openId = getApp().globalData.wxUserInfo.openId;
         wx.request({
           url:api.mine.getMyBusiness,
           data:t,
           method: "POST",
           header: {
             "content-type": "application/x-www-form-urlencoded"
           },
           success:function(res){
             if(res.statusCode==200&&res.data.code==200){
               var n = res.data.data;
                 r.setData({
                  buissbessData:res.data.data
                 },function(){
                  wx.hideLoading()
                 })
                  
                 wx.request({
                  url:api.mine.businessPerson,
                  data:{
                    openId:getApp().globalData.wxUserInfo.openId,
                    partId:res.data.data.partnerId
                  },
                  success:function(data){
                    if(data.statusCode==200&&data.data.code==200){
                      r.setData({
                        userList:data.data.data
                      })
                    }
                  }
                })
             }
           }
         })
      },    

    //添加员工
    adduser:function(e){
      console.log(e)
      var o = e.currentTarget.dataset;
      wx.navigateTo({
        url: "../add/add?partnerId=" + o.id
      })
    },
    // 跳转续费
    renew:function(){
      wx.navigateTo({
        url: "../renew/renew"
      })
    },
    middle(e){
      var id = e.currentTarget.dataset.openid
      wx.navigateTo({
        url: `../middle/middle?type=1&openid=${id}`
      });
    }
});